package com.jz.banner.screen.banner.net

import com.jz.banner.screen.banner.bean.CheckOutBean
import com.jz.banner.screen.banner.utils.ConstantUtils
import com.jz.banner.screen.bean.BaseBean
import com.jz.banner.screen.net.JsonConvert
import com.jz.banner.screen.utils.RxUtils
import com.lzy.okgo.OkGo
import com.lzy.okrx2.adapter.ObservableBody
import io.reactivex.Observable
import java.util.*

object GetApi {
    //private fun BaseBannerUrl() = "http://192.168.1.126:9506"

    private fun BaseBannerUrl() = "http://advert-api.jzxnm.com"
    //    private fun BaseBannerUrl() = "http://192.168.1.126:9506"
    val mAllowBG: String = "http://image.caiding.cn/uploads/APP/all_app_alow_horizontal_bg.png"


    /*广告*/
    val checkout: String = "${BaseBannerUrl()}/display/index/checkout"
    val getLaunch: String = "${BaseBannerUrl()}/display/index/getLaunch"
    val launchCensus: String = "${BaseBannerUrl()}/display/index/launchCensus"
    val submitInfo: String = "${BaseBannerUrl()}/display/index/submitInfo"

    val IMAGE_DEFAULT_URL: String = "http://img.jzxnm.com//uploads/images//9hJVWu1B0onC1nEsn2H9brulntbw5QqD.jpg"


    fun getData(params: SortedMap<String, Any?>, url: String?): Observable<BaseBean<CheckOutBean>> {
        return OkGo.post<BaseBean<CheckOutBean>>(url) //
            .params(ConstantUtils.getParams(params))
            .converter(object : JsonConvert<BaseBean<CheckOutBean>>() {}) //
            .adapt(ObservableBody()) //
            .compose(RxUtils.io())
    }
}